package com.pixiv.Interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class AdminInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("拦截器以拦截请求");
        //从请求头中获取token  验证用户是否登录
        String path = request.getServletPath();;
        System.out.println("path:" + path);
        return  true;
        //String tokenValue = redisUtil.getValue(token);
        //System.out.println("tokenValue = " + tokenValue);
        //if(tokenValue!=null){ //用户已登录 放行请求

        //}else{//重定向到登录页面
          //  response.sendRedirect(request.getContextPath()+"/login.jsp");
          //  return false;
        //}
    }
}